{% include 'link_css.html' %}
{% include 'script.html' %}
{% block content %}
    {% load bootstrap %}
    <style>
        .voilet_backgroup {
            background: #FFFFFF
        }
    </style>
    <div class="voilet_backgroup">
        <div class="wrapper wrapper-content animated fadeInRight">
            <div class="row">
                <div class="ibox float-e-margins">
                    <div class="ibox-content">
                        <form class="form-horizontal" id="auth_group_from" method="post" role="form">{% csrf_token %}

                            <div class="form-group"><label class="col-sm-2 control-label"> 权限组 </label>
                                <div class="col-sm-8">
                                    <li class="form-control">{{ auth_group.group_name }}</li>
                                </div>
                                <div class="col-sm-8" hidden="hidden"><input type="text" name="group_name"
                                                                             value="{{ auth_group.pk }}"
                                                                             class="form-control" readonly="readonly">
                                </div>
                            </div>
                            <div class="hr-line-dashed"></div>

                            <div class="form-group"><label class="col-sm-2 control-label"> 资产管理 </label>
                                <div class="col-sm-3">
                                    {{ form.select_host| bootstrap_horizontal }}
                                    {{ form.add_host| bootstrap_horizontal }}
                                    {{ form.bat_add_host| bootstrap_horizontal }}
                                    {{ form.edit_host| bootstrap_horizontal }}
                                    {{ form.update_host| bootstrap_horizontal }}
                                    {{ form.delete_host| bootstrap_horizontal }}
                                    {{ form.add_line_auth| bootstrap_horizontal }}
                                </div>
                            </div>
                            <div class="hr-line-dashed"></div>

                            <div class="form-group"><label class="col-sm-2 control-label"> 发布权限 </label>
                                <div class="col-sm-3">
                                    {{ form.auth_project| bootstrap_horizontal }}
                                    {{ form.auth_highstate| bootstrap_horizontal }}
                                </div>
                            </div>
                            <div class="hr-line-dashed"></div>

                            <div class="form-group"><label class="col-sm-2 control-label"> 用户管理 </label>
                                <div class="col-sm-3">
                                    {{ form.add_user| bootstrap_horizontal }}
                                    {{ form.edit_user| bootstrap_horizontal }}
                                    {{ form.edit_pass| bootstrap_horizontal }}
                                    {{ form.delete_user| bootstrap_horizontal }}
                                    {#                         {{ form.add_user_auth| bootstrap_horizontal }}#}
                                    {{ form.add_department| bootstrap_horizontal }}
                                </div>
                            </div>
                            <div class="hr-line-dashed"></div>

                            <div class="form-group"><label class="col-sm-2 control-label"> 系统管理 </label>
                                <div class="col-sm-3">
                                    {{ form.setup_system| bootstrap_horizontal }}
                                    {{ form.upload_system| bootstrap_horizontal }}
                                    {{ form.salt_keys| bootstrap_horizontal }}
                                </div>
                            </div>
                            <div class="hr-line-dashed"></div>

                            <div class="form-group"><label class="col-sm-2 control-label"> 项目管理 </label>
                                <div class="col-sm-3">
                                    {{ form.project_auth| bootstrap_horizontal }}
                                    {{ form.add_project| bootstrap_horizontal }}
                                    {{ form.edit_project| bootstrap_horizontal }}
                                    {{ form.delete_project| bootstrap_horizontal }}
                                </div>
                            </div>
                            <div class="hr-line-dashed"></div>

                            <div class="form-group"><label class="col-sm-2 control-label"> 机房管理 </label>
                                <div class="col-sm-3">
                                    {{ form.select_idc| bootstrap_horizontal }}
                                    {{ form.add_idc| bootstrap_horizontal }}
                                    {{ form.edit_idc| bootstrap_horizontal }}
                                    {{ form.del_idc| bootstrap_horizontal }}
                                </div>
                            </div>
                            <div class="hr-line-dashed"></div>

                            <div class="form-group"><label class="col-sm-2 control-label"> 日志 </label>
                                <div class="col-sm-2">
                                    {{ form.auth_log| bootstrap_horizontal }}
                                    {{ form.cmdb_log| bootstrap_horizontal }}
                                    {{ form.server_audit| bootstrap_horizontal }}
                                </div>
                            </div>
                            <div class="hr-line-dashed"></div>


                            <div class="form-group">
                                <div class="col-sm-4 col-sm-offset-5">
                                    <button class="btn btn-white" type="submit"> 重置</button>
                                    <a class="btn btn-primary" href="{% url 'role_permission_link' pk=auth_group.pk %}"
                                       onclick="return false"> 提交 </a>
                                </div>
                            </div>
                        </form>
                    </div>
                </div>
            </div>
        </div>
    </div>
    <script>
        $(document).ready(function () {
            $('.btn-primary').click(function () {
                jQuery.ajax({
                    url: $(this).attr('href'),                  // 提交的页面
                    data: $('#auth_group_from').serialize(), // 从表单中获取数据
                    type: "POST",                       // 设置请求类型为"POST"，默认为"GET"
                    dataType: 'text',
                    success: function (msg) {
                        console.info(msg);

                        let index = parent.layer.getFrameIndex(window.name); //获取当前窗体索引
                        parent.layer.close(index); //执行关闭
                    }
                });
            });
            return false;
        });
    </script>
{% endblock content %}
